﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using SmartSiteManagementSystem.IServices;
using SmartSiteManagementSystem.IRepository.WorkTask;
using SmartSiteManagementSystem.Models.WorkTask;
using System.Linq;

namespace SmartSiteManagementSystem.Services
{
    public class WorkTaskService:IWorkTaskService
    {
        private readonly ITaskSetInfoRepository _taskSetInfoRepository;

        private readonly IDemandingPlaceInfoRepository _demandingPlaceInfoRepository;

        private readonly ISupplyingPlaceInfoRepository _supplyingPlaceInfoRepository;


        private readonly ITaskInfoRepository _taskInfoRepository;

        private readonly ISupplyingPlaceMaterialInfoRepository _supplyingPlaceMaterialInfoRepository;

        public WorkTaskService(ITaskSetInfoRepository taskSetInfoRepository
            ,IDemandingPlaceInfoRepository demandingPlaceInfoRepository
            , ISupplyingPlaceInfoRepository supplyingPlaceInfoRepository 
            ,ITaskInfoRepository taskInfoRepository
            , ISupplyingPlaceMaterialInfoRepository supplyingPlaceMaterialInfoRepository)
        {
            _taskSetInfoRepository = taskSetInfoRepository;
            _demandingPlaceInfoRepository = demandingPlaceInfoRepository;
            _supplyingPlaceInfoRepository = supplyingPlaceInfoRepository;
            _taskInfoRepository = taskInfoRepository;
            _supplyingPlaceMaterialInfoRepository = supplyingPlaceMaterialInfoRepository;
        }

        #region  TaskSetInfo任务集

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetTaskSetInfoListCount(Hashtable param)
        {
            return _taskSetInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<TaskSetInfo> GetTaskSetInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _taskSetInfoRepository.GetList(param, orderBy, first, rows);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="setId"></param>
        /// <returns></returns>
        public TaskSetInfo GetTaskSetInfoById(int setId)
        {
            Hashtable param = new Hashtable();
            param.Add("set_id", setId);
            return _taskSetInfoRepository.Get(param);
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool UpdateTaskSetInfo(TaskSetInfo info)
        {
            bool back = _taskSetInfoRepository.Update(info);
            return back;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertTaskSetInfo(TaskSetInfo info)
        {
            return _taskSetInfoRepository.Insert(info);
        }




        #endregion

        #region   SupplyingPlace供应地 

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetSupplyingPlaceInfoListCount(Hashtable param)
        {
            return _supplyingPlaceInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<SupplyingPlaceInfo> GetSupplyingPlaceInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _supplyingPlaceInfoRepository.GetList(param, orderBy, first, rows);
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="supplyingPlaceId"></param>
        /// <returns></returns>
        public SupplyingPlaceInfo GetSupplyingPlaceInfoById(int supplyingPlaceId)
        {
            Hashtable param = new Hashtable();
            param.Add("supplying_place_id", supplyingPlaceId);
            return _supplyingPlaceInfoRepository.Get(param);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool UpdateSupplyingPlaceInfo(SupplyingPlaceInfo info)
        {
            bool back = _supplyingPlaceInfoRepository.Update(info);
            return back;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertSupplyingPlaceInfo(SupplyingPlaceInfo info)
        {
            return _supplyingPlaceInfoRepository.Insert(info);
        }

        #endregion

        #region demandingPlace需求地

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetDemandingPlaceInfoListCount(Hashtable param)
        {
            return _demandingPlaceInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<DemandingPlaceInfo> GetDemandingPlaceInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _demandingPlaceInfoRepository.GetList(param, orderBy, first, rows);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="demandingPlaceId"></param>
        /// <returns></returns>
        public DemandingPlaceInfo GetDemandingPlaceInfoById(int demandingPlaceId)
        {
            Hashtable param = new Hashtable();
            param.Add("demanding_place_id", demandingPlaceId);
            return _demandingPlaceInfoRepository.Get(param);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool UpdateDemandingPlaceInfo(DemandingPlaceInfo info)
        {
            bool back = _demandingPlaceInfoRepository.Update(info);
            return back;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertDemandingPlaceInfo(DemandingPlaceInfo info)
        {
            return _demandingPlaceInfoRepository.Insert(info);
        }
        #endregion


        #region TaskInfo 任务

        /// <summary>
        /// 
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public TaskInfo GetTaskInfoById(int taskId)
        {
            Hashtable param = new Hashtable();
            param.Add("task_id", taskId);
            return _taskInfoRepository.Get(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public int GetTaskInfoListCount(Hashtable param)
        {
            return _taskInfoRepository.GetCount(param);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <param name="orderBy"></param>
        /// <param name="first"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public IList<TaskInfo> GetTaskInfoList(Hashtable param, string orderBy, int first, int rows)
        {
            return _taskInfoRepository.GetList(param, orderBy, first, rows);
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool UpdateTaskInfo(TaskInfo info)
        {
            bool back = _taskInfoRepository.Update(info);
            return back;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int InsertTaskInfo(TaskInfo info)
        {
            return _taskInfoRepository.Insert(info);
        }
        #endregion

    }
}
